package com.pvdnc.riru.system_server.filter;

import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class PackageFilterManager {
    private static final String TAG=PackageFilterManager.class.getSimpleName();

    public static final PackageFilterManager INSTANCE=new PackageFilterManager();

    private final List<PackageFilter> mFilterList=new ArrayList<>();

    public void addFilter(PackageFilter filter){
        mFilterList.add(filter);
    }

    public boolean callFilter(String pkgName){
        for (PackageFilter filter:mFilterList){
            String alias=filter.getAlias();
            if(filter.onFilter(pkgName)) {
                Log.d(TAG,"pkg:"+pkgName+" has been filtered by filter:"+alias);
                return true;
            }
        }
        return false;
    }
}
